package com.hmall.item.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


@Data
@NoArgsConstructor
public class ItemDoc {

    private Long id;//id
    private String name;//name
    private Integer price;//价格
    private String image;//图片
    private String category;//分类
    private String brand;//品牌
    private String spec;//规格
    private Integer sold;//销量
    private Long commentCount;//评论数量
    private List<String> suggestion;

    public ItemDoc(Item item) {
        this.id = item.getId();
        this.name = item.getName();
        this.price = Math.toIntExact(item.getPrice());
        this.image = item.getImage();
        this.category = item.getCategory();
        this.brand = item.getBrand();
        this.spec = item.getSpec();
        this.sold = item.getSold();
        this.commentCount = Long.valueOf(item.getCommentCount());
        suggestion = new ArrayList<>();
        Collections.addAll(suggestion,brand,name,category);
    }
}
